[tox]
envlist =
    coverage-clean
    manifest
    flake8
    readme
    doc8
    docs
    py
    coverage-report

[testenv]
commands = coverage run -p -m pytest --durations=20 tests {posargs}
deps =
    coverage
    pytest
    bio2bel_kegg
    bio2bel_reactome
    bio2bel_wikipathways
whitelist_externals =
    /bin/cat
    /bin/cp
    /bin/mkdir

[testenv:coverage-clean]
deps = coverage
skip_install = true
commands = coverage erase

[testenv:manifest]
deps = check-manifest
skip_install = true
commands = check-manifest

[testenv:docs]
changedir = docs
extras =
    docs
commands =
    mkdir -p {envtmpdir}
    cp -r source {envtmpdir}/source
    sphinx-build -W -b html -d {envtmpdir}/build/doctrees {envtmpdir}/source {envtmpdir}/build/html
    sphinx-build -W -b coverage -d {envtmpdir}/build/doctrees {envtmpdir}/source {envtmpdir}/build/coverage
    cat {envtmpdir}/build/coverage/c.txt
    cat {envtmpdir}/build/coverage/python.txt

[testenv:coverage-report]
deps = coverage
skip_install = true
commands =
    coverage combine
    coverage report

[testenv:readme]
commands = rst-lint README.rst
skip_install = true
deps =
    restructuredtext_lint
    pygments

[testenv:flake8]
basepython = python3
skip_install = true
deps =
    flake8
    flake8-docstrings>=0.2.7
    flake8-import-order>=0.9
    pep8-naming
    flake8-colors
commands =
    flake8 src/compath/ tests/ setup.py

[testenv:pylint]
basepython = python3
deps =
    pyflakes
    pylint
commands =
    pylint src/compath

[testenv:doc8]
basepython = python3
skip_install = true
deps =
    sphinx
    doc8
commands =
    doc8 docs/source/

[testenv:bumpversion]
commands = bumpversion {posargs}
skip_install = true
deps =
    bumpversion

[testenv:build]
basepython = python3
skip_install = true
deps =
    wheel
    setuptools
commands =
    python setup.py -q sdist bdist_wheel

[testenv:release]
basepython = python3
skip_install = true
deps =
    {[testenv:build]deps}
    twine >= 1.5.0
commands =
    {[testenv:build]commands}
    twine upload --skip-existing dist/*

[testenv:finish]
basepython = python3
skip_install = true
whitelist_externals =
    /bin/git
    /usr/local/bin/git
deps =
    {[testenv:release]deps}
    bumpversion
commands =
    bumpversion release
    {[testenv:release]commands}
    git push
    bumpversion --message "Patch version [skip ci]" patch
